class Element {
  constructor(tagName, attributes = {}, children = []) {
      this.tagName = tagName;
      this.attributes = attributes;
      this.children = children;
  }

  render() {
      const ele = document.createElement(this.tagName);
      if (this.children && this.children.length > 0) {
          this.children.forEach((childElement) => {
            // 简单判断是节点还是文案
              if (childElement instanceof Element) {
                  ele.appendChild( childElement.render());
              } else if(typeof childElement === 'string') {
                  ele.appendChild(document.createTextNode(childElement));
              }
          })
      }
      return ele;
  }
}
